/**
 * @Author Stringzhua
 * @Date 2024/2/2 14:54
 * description:数组反转
 * 把数组的元素内容反转
 */
public class ArrayReverse {
    public static void main(String[] args) {
        /*
        * 规律
        * 1。把 arr[0] 和 arr[5] 进行交换 {66, 22, 33,44,55,11}
        * 2.把 arr[1] 和 arr[4] 进行交换{66, 55, 33 , 44, 22 , 11}
        * 3。把 arr[2] 和 arr[3] 进行交换{66 , 55 , 44 , 33, 22 , 11}
        * 4。一共要交换 3 次 = arr.length / 2
        * 5.每次交换时，对应的下标 是 arr[i] 和 arr[arr.length - 1 -i]
        * */
        int arr1[] = {11, 22, 33, 44, 55, 66};
        int temp = 0;
        int len = arr1.length;
        for (int i = 0; i < len / 2; i++) {
            temp = arr1[len - 1 - i];
            arr1[len - 1 - i] = arr1[i];
            arr1[i] = temp;
        }
        System.out.println("===arr1反转后数组===");
        for (int i = 0; i < arr1.length; i++) {
            System.out.println("arr1 = " + arr1[i]);
        }
    }
}
